﻿using YouTubeTranslator;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace t_YouTubeTranslator
{
    
    
    /// <summary>
    ///This is a test class for YouTubeMapperTest and is intended
    ///to contain all YouTubeMapperTest Unit Tests
    ///</summary>
    [TestClass()]
    public class YouTubeMapperTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Render
        ///</summary>
        [TestMethod()]
        public void RenderTest()
        {
            YouTubeMapper target = new YouTubeMapper(); // TODO: Initialize to an appropriate value
            string properResult = "<object width=\"560\" height=\"340\"><param name=\"movie\" value=\"http://www.youtube.com/v/dSfsMJgypdw&hl=en&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/dSfsMJgypdw&hl=en&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"560\" height=\"340\"></embed></object>";
            Assert.AreEqual(properResult, target.Render(new Uri("http://www.youtube.com/watch?v=dSfsMJgypdw")), "Basic URL should have rendered correctly!");
            Assert.AreEqual(properResult, target.Render(new Uri("http://www.youtube.com/v/dSfsMJgypdw&hl=en&fs=1&")), "Alternate URL should have rendered correctly!");
        }

        /// <summary>
        ///A test for CanRender
        ///</summary>
        [TestMethod()]
        public void CanRenderTest()
        {
            YouTubeMapper target = new YouTubeMapper(); // TODO: Initialize to an appropriate value

            Assert.IsTrue(target.CanRender(new Uri("http://www.youtube.com/v/dSfsMJgypdw&hl=en&fs=1&")), "Alternate form should work");
            Assert.IsFalse(target.CanRender(new Uri("http://www.nytimes.com")), "NYTimes web site not right!");
            Assert.IsTrue(target.CanRender(new Uri("http://www.youtube.com/watch?v=dSfsMJgypdw")), "This should have been ok!");
            Assert.IsTrue(target.CanRender(new Uri("http://www.YOUtube.com/watch?v=dSfsMJgypdw")), "Case should not matter!");
            Assert.IsFalse(target.CanRender(new Uri("http://www.YOUtube.com/watch?d=dSfsMJgypdw")), "Doesn't have the proper v in it!");
        }
    }
}
